1291B - Array Sharpening - CodeForces Solution


greedy implementation *1300

Please click on ads to support us..

C++ Code:

//ifstream fin("INPUT.TXT");
//ofstream fout("OUTPUT.TXT");
//fin.close();
//fout.close();
//cout << fixed << setprecition(6);
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ICC ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define str string
#define pb push_back
using namespace std;
void NOK()
{
    ll n, m;
    cin >> n >> m;
    cout << n * m / __gcd(n, m);
}
void zadacha_gradyschasov()
{
    ll n;
    cin >> n;
    ll k = 720 * n / 360;
    cout << "It is " <<  k / 60 << " hours " << k % 60 << " minutes.";
}
void a(){
    ll n;
    cin >> n;
    ll pos = 0, pos1 = 0, a[n + 12] = {};
    for(int i = 0; i < n; i ++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i ++){
        if(a[i] < i){
            break;
        }
        pos = i;
    }
    for(int i = n - 1; i >= 0; i --){
        if(a[i] < n - i - 1){
            break;
        }
        pos1 = i;
    }
    if(pos1 <= pos){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
}
int main(){
    ICC
    ld t = 1;
    cin >> t;
    while(t --){
        a();
    }
}


Comments

Submit
0 Comments
More Questions

1589C - Two Arrays
1510K - King's Task
126B - Password
462A - Appleman and Easy Task
839C - Journey
622A - Infinite Sequence
659C - Tanya and Toys
1266A - Competitive Programmer
234C - Weather
1332C - K-Complete Word
525C - Ilya and Sticks
1555C - Coin Rows
1324C - Frog Jumps
715A - Plus and Square Root
774D - Lie or Truth
1186D - Vus the Cossack and Numbers
505B - Mr Kitayuta's Colorful Graph
1324D - Pair of Topics
157B - Trace
34C - Page Numbers
279A - Point on Spiral
1294D - MEX maximizing
447A - DZY Loves Hash
23B - Party
63D - Dividing Island
1203E - Boxers
1547F - Array Stabilization (GCD version)
358A - Dima and Continuous Line
1385C - Make It Good
651A - Joysticks